#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>


int main()
{
    close(1);
    int fd = open("./log.txt", O_WRONLY | O_CREAT, 0644);
    //int fd = open("./log.txt", O_RDONLY);
    if(fd < 0) {
      perror("open");
    }
   // const char* msg = "hello bit!\n";
   // int cnt = 5;
   // while(cnt) {
   //   write(fd, msg, strlen(msg)); 
   //   cnt--;
   // }
    //char buf[128];
    //read(fd, buf, 128);
    //printf("fd:%d\n%s\n", fd, buf);
    printf("fd:%d\n", fd);
    printf("hello bit\n");
    printf("hello bit\n");
    printf("hello bit\n");
    
    fflush(stdout);
    close(fd);
    
    return 0;
}
